package org.scboy.common.dynamic.endpoint;

import java.util.ArrayList;
import java.util.List;

import org.scboy.common.dynamic.edge.BaseEdge;
import org.scboy.common.dynamic.node.BaseNode;

import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil;

/**
 * 链接点
 * @author 杨浩
 */
public class BaseEndpoint {
	
	/**
	 * 连接点ID
	 */
	private String id;
	
	/**
	 * 链接端点名称
	 */
	private String name;

	/**
	 * 数据缓存名称
	 */
	public String dataKey;
	
	/**
	 * 所属节点
	 */
	private BaseNode node;
	
	/**
	 * 流入链接
	 */
	private List<BaseEdge> InputEdge=new ArrayList<BaseEdge>();
	
	/**
	 * 流出链接
	 */
	private List<BaseEdge> outputEdge=new ArrayList<BaseEdge>();
	
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDataKey() {
		return dataKey;
	}

	public void setDataKey(String dataKey) {
		if(StrUtil.isEmpty(dataKey)) {
			this.dataKey =UUID.randomUUID().toString();
		}else {
			this.dataKey = dataKey;
		}
	}

	public BaseNode getNode() {
		return node;
	}

	public void setNode(BaseNode node) {
		this.node = node;
	}

	public List<BaseEdge> getInputEdge() {
		return InputEdge;
	}

	public void setInputEdge(BaseEdge inputEdge) {
		InputEdge.add(inputEdge);
	}

	public List<BaseEdge> getOutputEdge() {
		return outputEdge;
	}

	public void setOutputEdge(BaseEdge outputEdge) {
		this.outputEdge.add(outputEdge);
	}
	
	public Object getData() {
		return node.getData(dataKey);
	}
	
	
}
